package com.example.demo.controller;

import com.example.demo.model.Node;
import com.example.demo.service.RoutingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.annotation.MultipartConfig;
import java.util.List;
import java.util.Map;

/**
 * @author ：Docin
 * @date ：Created in 2020/9/11 10:47
 * @description：分簇算法
 * @modified By：
 */
@Controller
@RequestMapping(value="/devide")
@CrossOrigin
@MultipartConfig
public class ClusteringController {

    private Node[] nodeslist;

    @Autowired
    RoutingService routingService;

    @RequestMapping(value = "/companyLevel")
    @ResponseBody
//    @CrossOrigin
    //排编制的情况
    public Map<Integer,Object> companyResponse(@RequestParam("id[]")  Integer[] id){
        List<Node> tmpNodes = routingService.getsomeNodes(id);
        Node[] nodes = new Node[id.length];
        tmpNodes.toArray(nodes);
        Map<Integer, Object> clusters = routingService.wca(nodes);
        return clusters;
    }
}
